<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>在画布正中心画一个三角形</title>
    <style>
        canvas {
            background-color: rgba(0, 0, 0, 0.2);
        }
    </style>
</head>
<body>
    <canvas width="500" height="500"></canvas>
    <script>

        let canvas = document.querySelector('canvas')
        const context = canvas.getContext('2d')


        context.beginPath()
        context.moveTo(200,300)
        context.lineTo(200,100)
        context.lineTo(150,200)
        // context.closePath()
        context.fillStyle = 'red'
        context.fill()
    </script>
</body>
</html>